const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');

module.exports = {
  entry: path.join(__dirname, './src/js/app.jsx'),
  devServer: {
  	publicPath: '/',
    contentBase: './dist',
    hot: true,
  },
  module: {
  	rules: [
      // {
      //   test: /\.(js|jsx)$/,
      //   enforce: 'pre',
      //   exclude: /(node_modules|bower_components)/,
      //   use: "eslint-loader"
      // },
      {
        test: /\.(js|jsx)$/,
        use: "babel-loader"
      },
      {
        test: /\.(css|scss)/,
        use: [
          {
            loader: "style-loader" // creates style nodes from JS strings
          },
          {
            loader: "css-loader", // translates CSS into CommonJS
            options: {
              importLoaders: 1
            }
          },
          {
            loader: "sass-loader"
          },
          {
            loader: "postcss-loader"
          }

        ]
      },
  	]
  },
  plugins: [
    new HtmlWebpackPlugin({
        title: 'Redux Todo',
        inject: true,
        filename: path.join(__dirname, 'dist/index.html'),
        template: path.join(__dirname, '/src/index.html'),
    }),
    new webpack.NoEmitOnErrorsPlugin()
  ],
  output: {
    filename: 'app.js',
    path: path.resolve(__dirname, 'dist/js')
  },
};